package com.java.collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

public class CollectionsDemo {
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();
        list.add(55);
        list.add(87);
        list.add(32);
        list.add(11);
        list.add(47);
        //排序
        Collections.sort(list);
        System.out.println(list);
        //二分查找
        int pos = Collections.binarySearch(list,47);
        System.out.println("找到位置"+pos);
        //反转
        Collections.reverse(list);
        for (Integer num:list){
            System.out.println(num);
        }

        //打乱
        Collections.shuffle(list);
        System.out.println("---------随机打乱----------");
        for (Integer num:list){
            System.out.println(num);
        }
        int max = Collections.max(list);
        System.out.println("最大值是："+max);
    }
}
